const Router = require('koa-router');
const router = new Router();
const tool = require('../../tools/tool')
const {db, QueryTypes} = require("../../models/db");

router.post('/zq/list', async ctx => {
    try {
        let tenantId = ctx.user.tenantId;
        let sql = `SELECT a.*,b.name cbyName,'' state  from zq a INNER JOIN admin b on a.cby=b.id and a.tenantId=${tenantId} order by id desc`;
        let list = await db.query(sql, {type: QueryTypes.SELECT})
        if(list.length > 0) {
            list[0].state = '未结账'
        }
        return ctx.suc('', list);
    } catch (e) {
        return ctx.err('无返回数据')
    }
})

module.exports = router;
